﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace CNDM.UserControls.List
{
    public partial class ucListOther : System.Web.UI.UserControl
    {

        private string news_id = "0";
        private string cat_displayurl = "0";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["news_id"] != null && Request.QueryString["news_id"].ToString() != "")
            {
                news_id = Request.QueryString["news_id"].ToString();
            }

            if (Request.QueryString["cat_displayurl"] != null && Request.QueryString["cat_displayurl"].ToString() != "")
            {
                cat_displayurl = Request.QueryString["cat_displayurl"].ToString();
            }

            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            DataTable dt = new DataTable();
            dt = BO.Category.CategoryData.Get_Category_by_CatUrl(cat_displayurl);
            if (dt != null && dt.Rows.Count > 0)
            {
                
                DataTable dtList = new DataTable();
                dtList = BO.News.NewsData.Get_DanhSachTinCu(Convert.ToInt64(news_id), 5, Convert.ToInt32(dt.Rows[0]["Cat_ID"]));
                repListOld.DataSource = dtList;
                repListOld.DataBind();

                DataTable dtListNew = new DataTable();
                dtListNew = BO.News.NewsData.Get_DanhSachTinMoi(Convert.ToInt64(news_id), 5, Convert.ToInt32(dt.Rows[0]["Cat_ID"]));
                if (dtListNew == null || dtListNew.Rows.Count==0)
                    divListNew.Visible = false;
                else
                    divListNew.Visible = true;
                repListNew.DataSource = dtListNew;
                repListNew.DataBind();
            }

        }
    }
}